project(hccl_alg_research)

set(CMAKE_VERBOSE_MAKEFILE on)

add_library(hccl_alg_research SHARED)

set(HCCL_BASE_DIR ${TOP_DIR}/ace/comop/hccl/whole/hccl/)
target_include_directories(hccl_alg_research PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/inc
        ${HCCL_BASE_DIR}/pub_inc
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/alg_template
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/mc2_handler
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/alg_template/component/inc
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/communicator
        ${CMAKE_CURRENT_SOURCE_DIR}/../base/communicator/legacy
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl/inc
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl/legacy
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl/operator
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl/resource_manager
        ${CMAKE_CURRENT_SOURCE_DIR}/../impl/task
        ${HCCL_BASE_DIR}/algorithm/alg_research/pub_inc
        ${HCCL_BASE_DIR}/../../../../../inc/external
        ${HCCL_BASE_DIR}/../../../../../inc/external/hccl
        ${HCCL_BASE_DIR}/../../../../../inc/hccl
        ${HCCL_BASE_DIR}/../../../../../inc
        ${HCCL_BASE_DIR}/hccl_comm/inc
        ${HCCL_BASE_DIR}/algorithm/pub_inc
        ${TOP_DIR}/ace/comop/hccl/whole/hccl/platform/inc/adapter/
        ${TOP_DIR}/ace/comop/hccl/whole/hccl/platform/inc
        ${TOP_DIR}/abl/msprof/inc
        ${TOP_DIR}/abl/atrace/inc/utrace
        ${TOP_DIR}/abl/mmpa/inc/mmpa
        ${TOP_DIR}/ace/npuruntime/inc
        ${TOP_DIR}/ace/npuruntime/inc/external
        ${TOP_DIR}/drivers/network/inc
        ${TOP_DIR}/metadef/inc/common/util/error_manager/
        ${TOP_DIR}/metadef/inc/external/
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_all_gather
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_all_reduce
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_alltoall
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_alltoallv
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_broadcast
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_reduce
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_reduce_scatter
        ${CMAKE_CURRENT_SOURCE_DIR}/alg_template/temp_scatter
        )

target_compile_definitions(hccl_alg_research  PRIVATE
    $<$<STREQUAL:${PRODUCT_SIDE},host>:_GLIBCXX_USE_CXX11_ABI=0>
)

target_compile_options(hccl_alg_research PRIVATE
    -Werror
    -fno-common
    -fno-strict-aliasing
    -pipe
    -O3
    -std=c++14
    -fstack-protector-all
)

target_link_options(hccl_alg_research PRIVATE
    -Wl,-z,relro
    -Wl,-z,now
    -Wl,-z,noexecstack
)

target_link_libraries(hccl_alg_research PRIVATE
    $<BUILD_INTERFACE:slog_headers>
    -Wl,--no-as-needed
    c_sec
    slog
    -Wl,--no-as-needed
    hccl_plf
    ofed_headers
)

add_subdirectory(communicator)
add_subdirectory(alg_template)
add_subdirectory(aiv)

install(TARGETS  hccl_alg_research
    LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}  OPTIONAL
)

install_package(
    PACKAGE hccl
    TARGETS hccl_alg_research
)